﻿/*
* @Author： whg
* @Date : 2021-1-19
* @Desc : 
*/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Text;
using XNode;
public class DialogueNode : BaseNode
{
    [Input(backingValue = ShowBackingValue.Always)]
    public BaseNode upLink;
    [Output(backingValue = ShowBackingValue.Always)]
    public BaseNode downLink;
    public override StringBuilder ToTable()
    {
        StringBuilder result = new StringBuilder(1024);
        string space = "				";
        result.Append(space + "{\n					type = Config.StoryConst."+dialogueType+",\n");
        space += "	";
        switch (dialogueType)
        {
            case DialogueType.StoryDialog:
                result.Append(space + "target = \"" + Dialog_target + "\",\n");
                result.Append(space + "id = [[" + Dialog_id + "]],\n");
                result.Append(space + "scale = " + Dialog_scale + ",\n");
                result.Append(space + "time = " + Dialog_time + ",\n");
                result.Append(space + "content = [[" + Dialog_content + "]]\n");
                break;
            case DialogueType.StoryTalkBoard:
                result.Append(space + "wait = \"" + Talk_wait + "\",\n");
                result.Append(space + "target = \"" + Talk_target + "\",\n");
                result.Append(space + "ins_id = [[" + TalkBoard_ins_id + "]],\n");
                result.Append(space + "time = " + TalkBoard_time + ",\n");
                result.Append(space + "width = " + TalkBoard_width + ",\n");
                result.Append(space + "offset = {x=" + TalkBoard_offset.x + ",y=" + TalkBoard_offset.y + "},\n");
                result.Append(space + "content = [[" + TalkBoard_content + "]]\n");
                if (TalkBoard_animation!="")
                    result.Append(space + "animation = \"" + TalkBoard_animation + "\"\n");
                if(TalkBoard_func!="")
                    result.Append(space + "func = " + TalkBoard_func + "\n");
                break;
            case DialogueType.BlackMaskText:
                result.Append(space + "bool = " + IsBlack.ToString().ToLower() + ",\n");
                result.Append(space + "time = " + BlackMask_time + ",\n");
                if(IsBlack)
                {
                    result.Append(space + "fontSize = " + fontSize + ",\n");
                    result.Append(space + "lineSpacing = " + lineSpacing + ",\n");
                    result.Append(space + "content = [[" + BlackMask_content + "]]\n");
                }
                break;
        }
        result.Append("				},");
        return result;
    }
    public enum DialogueType { StoryDialog, StoryTalkBoard, BlackMaskText }
    [Tooltip("剧情对话,剧情气泡,黑幕文字")]
    public DialogueType dialogueType = DialogueType.StoryDialog;
    public enum DialogueTarget {Actor,Monster,MainRole,SceneNpc }
    #region StoryDialog
    [Tooltip("MainRole Npc  Monster")]
    public DialogueTarget Dialog_target = DialogueTarget.Monster;
    [Tooltip("类型id,如果目标是MainRole,id就是me")]
    public string Dialog_id = "10000";
    [Tooltip("控制模型尺寸")]
    public int Dialog_scale = 100;
    [Tooltip("持续时间，单位为s")]
    public float Dialog_time = 4;
    [Tooltip("文字内容")]
    [TextArea]
    public string Dialog_content = "这里水流湍急，还是让海豚载你一程吧！";
    #endregion

    #region StoryTalkBoard
    [Tooltip("目标类型Actor,MainRole,SceneNpc")]
    public DialogueTarget Talk_target = DialogueTarget.Actor;
    [Tooltip("是否需要等待")]
    public bool Talk_wait = true;
    [Tooltip("实例id")]
    public string TalkBoard_ins_id = "10000";
    [Tooltip("持续时间，单位为s")]
    public float TalkBoard_time = 4;
    public int TalkBoard_width = 200;
    [Tooltip("气泡偏移值")]
    public Vector2 TalkBoard_offset = new Vector2(0, 10);
    [Tooltip("Npc 动画名字casual,没有特殊动画就不用填")]
    public string TalkBoard_animation;
    [Tooltip("文字内容")]
    [TextArea]
    public string TalkBoard_content = "这里水流湍急，还是让海豚载你一程吧！";
    [Tooltip("特殊功能回调，没有特殊要求不用填，有特殊功能要程序填")]
    [TextArea]
    public string TalkBoard_func = "";
    #endregion

    #region BlackMaskText
    [Tooltip("是否黑屏,不选就是取消黑屏")]
    public bool IsBlack;
    [Tooltip("渐变时间")]
    public float BlackMask_time = 1;
    [Tooltip("只有黑屏时才可选显示文字，否则不填\n文字大小，不需要文字则不填")]
    public int fontSize = 28;
    [Tooltip("文字行间隔，不需要文字则不填")]
    public float lineSpacing = 2;
    [Tooltip("文字内容，不需要文字则不填")]
    [TextArea]
    public string BlackMask_content = "这里水流湍急，还是让海豚载你一程吧！";
    #endregion
}
